Skip to content

fix:Add check for empty search results to prevent array out of bounds#769

Open
SYaoJun wants to merge 1 commit intoapache:masterfrom
SYaoJun:0306_index_0
Open

fix:Add check for empty search results to prevent array out of bounds#769
SYaoJun wants to merge 1 commit intoapache:masterfrom
SYaoJun:0306_index_0

Conversation

@SYaoJun
Copy link
Contributor

@SYaoJun SYaoJun commented Mar 6, 2026

What changes were proposed in this pull request?

Directly accessing index 0 carries a risk.
It is better to check that the length is greater than zero in advance.

Document firstDoc = searcher.doc(topDocs.scoreDocs[0].doc);

How was this PR tested?

  • Tests have Added for the changes
  • Production environment verified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant